
var gameInfo = require("gameStrategy");

cc.Class({
  extends: cc.Component,

  properties: {
      verticalBar: {
          type: cc.ProgressBar,
          default: null
      },

      magicValueNode: {
        default: null,
        type: cc.Node
      },
  },

  onLoad: function () {
      this.verticalBar.progress = 0;
      this.targetScore = gameInfo.gameRunInfo.superMagicMax;
      this.magicValueAnimation = this.magicValueNode.getComponent(cc.Animation);
      this.magicValueNode.active = false;
      this.magicValueAnimation.stop();   
  },

  update: function (dt) {
  },
    
  updateBaseScore: function ( targetScore ){
    var progress = targetScore/this.targetScore;
    if(progress >= 1){
      progress = 1.0;
    }
    this.verticalBar.progress = progress;
  },

  changePlayerStateNormal: function (){
    this.magicValueNode.active = false;
    this.magicValueAnimation.stop();   
  },

  changePlayerStateSuper: function (){
    this.magicValueNode.active = true;
    this.magicValueAnimation.play();
  },
});
